<template>
  <div class="app-container">

    <el-card v-show="histogramShow">
      <div class="logo-wrapper">
        <div class="logo">
          柱状图
        </div>
      </div>
      <ve-histogram
        :data="columnarData"
        :settings="columnarSet"
        width="1200px" height="400px"
      ></ve-histogram>
    </el-card>

    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="道路名称" prop="roadName">
        <el-input
          v-model="queryParams.roadName"
          placeholder="请输入道路名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="隧道名称" prop="tunnelName">
        <el-input
          v-model="queryParams.tunnelName"
          placeholder="请输入隧道名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="评定等级" prop="pclass">
        <el-input
          v-model="queryParams.pclass"
          placeholder="请输入评定等级"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="评定人" prop="adjuster">
        <el-input
          v-model="queryParams.adjuster"
          placeholder="请输入评定人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['civil:total:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['civil:total:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['civil:total:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['civil:total:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="totalList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="编号" align="center" prop="technologyId" />
      <el-table-column label="道路名称" align="center" prop="roadName" />
      <el-table-column label="隧道名称" align="center" prop="tunnelName" />
      <el-table-column label="管养单位" align="center" prop="maintenanceOrganization" />
      <el-table-column label="评分" align="center" prop="grade" />
      <el-table-column label="评定等级" align="center" prop="pclass" />
      <el-table-column label="评定日期" align="center" prop="adjustData" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.adjustData, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="评定人" align="center" prop="adjuster" />
      <el-table-column label="记录人" align="center" prop="record" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['civil:total:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleTotalCheck(scope.row)"
            v-hasPermi="['civil:total:edit']"
          >详情</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['civil:total:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改土建结构技术状况评定对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="650px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="110px">
        <el-row>
        <el-col :span="12">
        <el-form-item label="道路名称" prop="roadName">
          <el-input v-model="form.roadName" placeholder="请输入道路名称" />
        </el-form-item>
        </el-col>
        <el-col :span="12">
        <el-form-item label="隧道名称" prop="tunnelName">
          <el-input v-model="form.tunnelName" placeholder="请输入隧道名称" />
        </el-form-item>
        </el-col>
        </el-row>
        <el-form-item label="管养单位" prop="maintenanceOrganization">
          <el-input v-model="form.maintenanceOrganization" placeholder="请输入管养单位" />
        </el-form-item>
        <p>----------------------------------------请填写各分项权重（权重和为100）--------------------------------------</p>
       <el-row>
        <el-col :span="12">
        <el-form-item label="洞口权重" prop="tunnelHoleLimit">
          <el-input v-model="form.tunnelHoleLimit" placeholder="请输入洞口权重" />
        </el-form-item>
        </el-col>
        <el-col :span="12">
        <el-form-item label="洞门权重" prop="tunnelDoorLimit">
          <el-input v-model="form.tunnelDoorLimit" placeholder="请输入洞门权重" />
        </el-form-item>
        </el-col>
        <el-col :span="12">
        <el-form-item label="衬砌权重" prop="linningLimit">
          <el-input v-model="form.linningLimit" placeholder="请输入衬砌权重" />
        </el-form-item>
        </el-col>
        <el-col :span="12">
        <el-form-item label="路面权重" prop="roadsurfaceLimit">
          <el-input v-model="form.roadsurfaceLimit" placeholder="请输入路面权重" />
        </el-form-item>
        </el-col>
        <el-col :span="12">
        <el-form-item label="检修道权重" prop="jianxiudaoLimit">
          <el-input v-model="form.jianxiudaoLimit" placeholder="请输入检修道权重" />
        </el-form-item>
        </el-col>
        <el-col :span="12">
        <el-form-item label="排水设施权重" prop="waterLimit">
          <el-input v-model="form.waterLimit" placeholder="请输入排水设施权重" />
        </el-form-item>
        </el-col>
        <el-col :span="12">
        <el-form-item label="吊顶权重" prop="topLimit">
          <el-input v-model="form.topLimit" placeholder="请输入吊顶权重" />
        </el-form-item>
        </el-col>
        <el-col :span="12">
        <el-form-item label="装饰物权重" prop="directLimit">
          <el-input v-model="form.directLimit" placeholder="请输入装饰物权重" />
        </el-form-item>
        </el-col>
       </el-row>
        <el-form-item label="标志标线权重" prop="markingLimit">
          <el-input v-model="form.markingLimit" placeholder="请输入标志标线权重" />
        </el-form-item>
         <p>--------------------------------------------------------------------------------------------------------------------------</p>
        <el-form-item label="本次评定日期" prop="adjustData">
          <el-date-picker clearable
            v-model="form.adjustData"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择本次评定日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="评定人" prop="adjuster">
          <el-input v-model="form.adjuster" placeholder="请输入评定人" />
        </el-form-item>
        <el-form-item label="记录人" prop="record">
          <el-input v-model="form.record" placeholder="请输入记录人" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 查看土建结构技术状况评定对话框 -->
    <el-dialog :title="title" :visible.sync="totalcheck" width="800px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
        <el-col :span="12">
        <el-form-item label="道路名称" prop="roadName">
          <el-input v-model="form.roadName" placeholder="请输入道路名称" />
        </el-form-item>
        </el-col>
        <el-col :span="12">
        <el-form-item label="隧道名称" prop="tunnelName">
          <el-input v-model="form.tunnelName" placeholder="请输入隧道名称" />
        </el-form-item>
        </el-col>
        <el-form-item label="管养单位" prop="maintenanceOrganization" label-width="100px">
          <el-input v-model="form.maintenanceOrganization" placeholder="请输入管养单位" />
        </el-form-item>
        <el-col :span="12">
        <el-form-item label="洞口最大值" prop="tunnelHoleMax">
          <el-input v-model="form.tunnelHoleMax" placeholder="请输入洞口最大值" />
        </el-form-item>
        </el-col>
        <el-col :span="12">
        <el-form-item label="洞口权重" prop="tunnelHoleLimit">
          <el-input v-model="form.tunnelHoleLimit" placeholder="请输入洞口权重" />
        </el-form-item>
        </el-col>
        <el-col :span="12">
        <el-form-item label="洞门最大值" prop="tunnelDoorMax">
          <el-input v-model="form.tunnelDoorMax" placeholder="请输入洞门最大值" />
        </el-form-item>
        </el-col>
        <el-col :span="12">
        <el-form-item label="洞门权重" prop="tunnelDoorLimit">
          <el-input v-model="form.tunnelDoorLimit" placeholder="请输入洞门权重" />
        </el-form-item>
        </el-col>
        <el-col :span="12">
        <el-form-item label="衬砌最大值" prop="liningMax">
          <el-input v-model="form.liningMax" placeholder="请输入衬砌最大值" />
        </el-form-item>
        </el-col>
        <el-col :span="12">
        <el-form-item label="衬砌权重" prop="linningLimit">
          <el-input v-model="form.linningLimit" placeholder="请输入衬砌权重" />
        </el-form-item>
        </el-col>
        <el-col :span="12">
        <el-form-item label="路面最大值" prop="roadsurfaceMax">
          <el-input v-model="form.roadsurfaceMax" placeholder="请输入路面最大值" />
        </el-form-item>
        </el-col>
        <el-col :span="12">
        <el-form-item label="路面权重" prop="roadsurfaceLimit">
          <el-input v-model="form.roadsurfaceLimit" placeholder="请输入路面权重" />
        </el-form-item>
        </el-col>
        <el-col :span="12">
        <el-form-item label="检修道最大值" prop="jianxiudaoMax">
          <el-input v-model="form.jianxiudaoMax" placeholder="请输入检修道最大值" />
        </el-form-item>
        </el-col>
        <el-col :span="12">
        <el-form-item label="检修道权重" prop="jianxiudaoLimit">
          <el-input v-model="form.jianxiudaoLimit" placeholder="请输入检修道权重" />
        </el-form-item>
        </el-col>
        <el-col :span="12">
        <el-form-item label="排水设施最大值" prop="waterMax">
          <el-input v-model="form.waterMax" placeholder="请输入排水设施最大值" />
        </el-form-item>
        </el-col>
        <el-col :span="12">
        <el-form-item label="排水设施权重" prop="waterLimit">
          <el-input v-model="form.waterLimit" placeholder="请输入排水设施权重" />
        </el-form-item>
        </el-col>
        <el-col :span="12">
        <el-form-item label="吊顶最大值" prop="topMax">
          <el-input v-model="form.topMax" placeholder="请输入吊顶最大值" />
        </el-form-item>
        </el-col>
        <el-col :span="12">
        <el-form-item label="吊顶权重" prop="topLimit">
          <el-input v-model="form.topLimit" placeholder="请输入吊顶权重" />
        </el-form-item>
        </el-col>
        <el-col :span="12">
        <el-form-item label="装饰物最大值" prop="directMax">
          <el-input v-model="form.directMax" placeholder="请输入装饰物最大值" />
        </el-form-item>
        </el-col>
        <el-col :span="12">
        <el-form-item label="装饰物权重" prop="directLimit">
          <el-input v-model="form.directLimit" placeholder="请输入装饰物权重" />
        </el-form-item>
        </el-col>
        <el-col :span="12">
        <el-form-item label="标志标线最大值" prop="markingMax">
          <el-input v-model="form.markingMax" placeholder="请输入标志标线最大值" />
        </el-form-item>
        </el-col>
        <el-col :span="12">
        <el-form-item label="标志标线权重" prop="markingLimit">
          <el-input v-model="form.markingLimit" placeholder="请输入标志标线权重" />
        </el-form-item>
        </el-col>
        <el-form-item label="评分" prop="grade">
          <el-input v-model="form.grade" placeholder="请输入评分" />
        </el-form-item>
        <el-form-item label="评定等级" prop="pclass">
          <el-input v-model="form.pclass" placeholder="请输入评定等级" />
        </el-form-item>
        <el-form-item label="本次评定日期" prop="adjustData">
          <el-date-picker clearable
                          v-model="form.adjustData"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择本次评定日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="评定人" prop="adjuster">
          <el-input v-model="form.adjuster" placeholder="请输入评定人" />
        </el-form-item>
        <el-form-item label="记录人" prop="record">
          <el-input v-model="form.record" placeholder="请输入记录人" />
        </el-form-item>
        <el-form-item label="养护措施建议" prop="suggest">
          <el-input v-model="form.suggest" placeholder="请输入养护措施建议" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancel">返 回</el-button>
      </div>
    </el-dialog>

  </div>
</template>



<script>
import { listTotal, getTotal, delTotal, addTotal, updateTotal } from "@/api/civil/total";
/*import { use } from "echarts/core";
import { CanvasRenderer } from "echarts/renderers";
import { PieChart, RadarChart } from "echartsarts";
import {
  TitleComponent,
  TooltipComponent,
  LegendComponent,
} from "echarts/components";*/



export default {
  name: "Total",
  data() {
    return {


      chartData: [],
      columnarData: {
        columns: ["data", "课程目标达成目标值", "达成值", "课程目标达成度"],
        rows: [
           {
            data: "课程目标1",
            课程目标达成目标值: 1393,
            达成值: 1093,
            课程目标达成度: 100,
             },
             {
             data: "课程目标2",
             课程目标1: 3530,
             课程目标2: 3230,
             课程目标3: 1230,
            },
        ],
      },
      columnarSet:{},
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 土建结构技术状况评定表格数据
      totalList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      totalcheck:false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        roadName: null,
        tunnelName: null,
        maintenanceOrganization: null,
        tunnelHoleMax: null,
        tunnelHoleLimit: null,
        tunnelDoorMax: null,
        tunnelDoorLimit: null,
        liningMax: null,
        linningLimit: null,
        roadsurfaceMax: null,
        roadsurfaceLimit: null,
        jianxiudaoMax: null,
        jianxiudaoLimit: null,
        waterMax: null,
        waterLimit: null,
        topMax: null,
        topLimit: null,
        directMax: null,
        directLimit: null,
        markingMax: null,
        markingLimit: null,
        grade: null,
        pclass: null,
        adjustData: null,
        adjuster: null,
        record: null,
        suggest: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        roadName:[
          {required:true, message:"请填写该项内容", trigger:"blur"}
        ],
        tunnelName:[
          {required:true, message:"请填写该项内容", trigger:"blur"}
        ],
        maintenanceOrganization:[
          {required:true, message:"请填写该项内容", trigger:"blur"}
        ],
        tunnelHoleLimit:[
          {required:true, message:"请填写该项内容", trigger:"blur"}
        ],
        tunnelDoorLimit:[
          {required:true, message:"请填写该项内容", trigger:"blur"}
        ],
        linningLimit:[
          {required:true, message:"请填写该项内容", trigger:"blur"}
        ],
        roadsurfaceLimit:[
          {required:true, message:"请填写该项内容", trigger:"blur"}
        ],
        jianxiudaoLimit:[
          {required:true, message:"请填写该项内容", trigger:"blur"}
        ],
        waterLimit:[
          {required:true, message:"请填写该项内容", trigger:"blur"}
        ],
        topLimit:[
          {required:true, message:"请填写该项内容", trigger:"blur"}
        ],
        directLimit:[
          {required:true, message:"请填写该项内容", trigger:"blur"}
        ],
        markingLimit:[
          {required:true, message:"请填写该项内容", trigger:"blur"}
        ],
        adjustData:[
          {required:true, message:"请填写该项内容", trigger:"blur"}
        ],
        adjuster:[
          {required:true, message:"请填写该项内容", trigger:"blur"}
        ],
        record:[
          {required:true, message:"请填写该项内容", trigger:"blur"}
        ],
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询土建结构技术状况评定列表 */
    getList() {
      this.loading = true;
      listTotal(this.queryParams).then(response => {
        this.totalList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.totalcheck=false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        technologyId: null,
        roadName: null,
        tunnelName: null,
        maintenanceOrganization: null,
        tunnelHoleMax: null,
        tunnelHoleLimit: null,
        tunnelDoorMax: null,
        tunnelDoorLimit: null,
        liningMax: null,
        linningLimit: null,
        roadsurfaceMax: null,
        roadsurfaceLimit: null,
        jianxiudaoMax: null,
        jianxiudaoLimit: null,
        waterMax: null,
        waterLimit: null,
        topMax: null,
        topLimit: null,
        directMax: null,
        directLimit: null,
        markingMax: null,
        markingLimit: null,
        grade: null,
        pclass: null,
        adjustData: null,
        adjuster: null,
        record: null,
        suggest: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.technologyId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加土建结构技术状况评定";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const technologyId = row.technologyId || this.ids
      getTotal(technologyId).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改土建结构技术状况评定";
      });
    },

//查看按钮
    handleTotalCheck(row) {
      this.reset();
      const technologyId = row.technologyId || this.ids
      getTotal(technologyId).then(response => {
        this.form = response.data;
        this.totalcheck = true;
        this.title = "查看土建结构技术状况评定表";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.technologyId != null) {
            updateTotal(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addTotal(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const technologyIds = row.technologyId || this.ids;
      this.$modal.confirm('是否确认删除土建结构技术状况评定编号为"' + technologyIds + '"的数据项？').then(function() {
        return delTotal(technologyIds);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('civil/total/export', {
        ...this.queryParams
      }, `total_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
